using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using spaceattack.Helpers;

namespace spaceattack.GameObjects
{
    class Enemy : GameObject
    {
        private EnemyStrategy strategy;
        private int shootTimeOut = RandomHelper.Next(200) + 50;

        public bool ReadyToShoot
        {
            get
            {
                return shootTimeOut == 0;
            }
        }
        public override bool OnScreen
        {
            get
            {
                return position.Y < SpaceAttackGame.Height;

            }
        }
        public Enemy(Vector2 position, float scale, EnemyStrategy enemyStrategy)
            : base(position, scale, LoadHelper.Textures[TextureEnum.Enemy])
        {
            this.strategy = enemyStrategy;
        }

        public override void Update()
        {
            if (strategy == EnemyStrategy.Simple)
            {
                position.Y += 8;
            }
            if (strategy == EnemyStrategy.Advanced)
            {
                if (position.Y > 0)
                    position.X += (position.Y%161 - 80)/8;
                position.Y += 4;
            }

            shootTimeOut--;
            if (shootTimeOut < 0)
                shootTimeOut = RandomHelper.Next(200) + 50;

        }
    }

    public enum EnemyStrategy
    {
        Simple,
        Advanced
    }
}
